
<!--banner开始-->
<div class="banner">
	<img src="<?php echo json_decode($banner[0]['path'])[0];?>"/>
</div>
<!--contact开始-->
<div class="contact">
	<p>您的位置:<a href="contact_us.html">联系我们</a></p>
	<div class="con_way">
        <div class="top"><img src="<?php echo IMG;?>telephone.jpg"/><p>联系方式</p><span></span></div>
        <div class="way">
            <p><img src="<?php echo IMG;?>call.jpg"/>联系电话：<?php echo $data['telephone'];?></p>
            <p><img src="<?php echo IMG;?>linkman.jpg"/><span>联系人：</span><?php echo $data['name']?></p>
            <p><img src="<?php echo IMG;?>email.jpg"/>邮箱：<?php echo $data['email']?></p>
            <p><img src="<?php echo IMG;?>site.jpg"/>地址：<span><?php echo $data['address']?></span></p>
        </div>
        <div id="dituContent"></div>
    </div>
</div>
<div class="message">
        <div class="live">
        <div class="top">
        	<img src="<?php echo IMG;?>wechat.jpg"/>
            <p>在线留言</p>
            <span></span>
         </div>
         <form action="" method="post" id="message">
               <label>
                    <span>昵称：</span><input type="nanme" name="" value="" id="nickname">
               </label>
               <label>
                    <span>联系电话：</span><input type="" name="" value="" id="phone" />
                </label>
                <label>
                    <span>邮箱：</span><input type="" name="" value="" id="email" />
                </label>
               
                <label>
                    <span>内容：</span><textarea name="content" value="" id="content"></textarea>
                </label>
         
                <label>
                	<span>验证码：</span><input type="" name="" value="" id="verify" /><img src="index.php?c=contact_us&v=verify" id="verimg"  onclick="this.src=this.src" />

                    <button>提交留言</button>
                </label>
         </form>
     </div>
</div>

<script type="text/javascript">

     $("#nickname").focus(function(){

        var nickname = $(this).val();
        if(nickname == '昵称不可为空'){
            $(this).val('').css('color','black');
        }
       
    })


    $("#nickname").blur(function(){

        var nickname = $(this).val();


        if(nickname == ''){
            $(this).val('昵称不可为空').css('color','red');
             return false;
        }



      
    })

    $("#phone").focus(function(){

        var phone = $(this).val();
        if(phone == '联系电话不可为空' || phone=='格式错误'){
            $(this).val('').css('color','black');
        }
       
    })


    $("#phone").blur(function(){

        var phone = $(this).val();


        if(phone == ''){
            $(this).val('联系电话不可为空').css('color','red');
             return false;
        }

        $.ajax({
            url:'',

            type: 'post',

            data:{phone:phone} ,

            dataType : 'json',

            success : function(msg){

                if(msg==0){

                      $("#phone").val('格式错误').css('color','red');
                      return false;

                }
            }

        })

      
    })


    


     $("#email").focus(function(){

        var email = $(this).val();

        if(email == '邮箱不可为空' || email == '格式错误'){
            $(this).val('').css('color','black');
        }
       
    })


    $("#email").blur(function(){

        var email = $(this).val();


        if(email == ''){
            $(this).val('邮箱不可为空').css('color','red');
            return false;
        }

          $.ajax({
            url:'',

            type: 'post',

            data:{email:email} ,

            dataType : 'json',

            success : function(msg){

                if(msg==0){

                      $("#email").val('格式错误').css('color','red');
                      return false;

                }
            }

        })

      
    })

    $("#content").focus(function(){

        var content = $(this).val();

        if(content == '内容不可为空'){
            $(this).val('').css('color','black');
        }
       
    })


    $("#content").blur(function(){

        var content = $(this).val();


        if(content == ''){
            $(this).val('内容不可为空').css('color','red');
            return false;
        }

       
    })
     $("#verify").focus(function(){

        var verify = $(this).val();

        if(verify == '验证码不可为空'){
            $(this).val('').css('color','black');
        }
       
    })


    $("#verify").blur(function(){

        var verify = $(this).val();


        if(verify == ''){
            $(this).val('验证码不可为空').css('color','red');
            return false;
        }

       
    })

    $("#message").submit(function(){

        $("#nickname").focus();
        $("#phone").focus();
        $("#email").focus();
        $("#content").focus();
        $("#verify").focus();


        var snickname = $("#nickname").val();
        var sphone = $("#phone").val();
        var semail = $("#email").val();
        var scontent = $("#content").val();
        var sverify = $("#verify").val();

        var cnickname = $("#nickname").css('color');
        var cphone = $("#phone").css('color');
        var cemail = $("#email").css('color');
        var ccontent = $("#content").css('color');
        var cverify = $("#verify").css('color');


      
        if(cnickname=="rgb(255, 0, 0)" || cphone=="rgb(255, 0, 0)" || cemail=="rgb(255, 0, 0)" || ccontent=="rgb(255, 0, 0)" || cverify=="rgb(255, 0, 0)"){

             alert("请确认填写正确后提交");return false;

        }
          
          // }
     

        $.ajax({
            url : '',

            type: 'post',

            data:{snickname:snickname,sphone:sphone,semail:semail,scontent:scontent,sverify:sverify,submit:1},

            dataType:'json',

            success :function(msg){
                


                if(msg.ver != 1){
                   alert("验证码错误");return false;
                }else if(msg.int == 0){
                    alert('留言失败');return false;
                }else{
                    alert('留言成功');location.href='index.php?c=contact_us&hid=5';
                }


            }
        })
            

        return false;
        // if(){

        // }
    })

    


</script>
